fn is_prime(n: u64) -> bool {
    match n {
        0 | 1 => false,
        2 => true,
        _ if n % 2 == 0 => false,
        _ => {
            let limit = (n as f64).sqrt() as u64;
            (3..=limit).step_by(2).all(|i| n % i != 0)
        }
    }
}

fn find_num(mut res: u64) -> u64 {
    loop {
        res += 2;
        if is_prime(res) {
            continue;
        }
        let mut sign = false;
        for i in 2..res {
            if is_prime(i) {
                let remain = res - i;
                if remain % 2 == 0 {
                    let num = (remain as f64 / 2.0).sqrt();
                    if num.fract() == 0.0 {
                        sign = true;
                        break;
                    }
                }
            }
        }
        if !sign {
            return res;
        }
    }
}

pub fn goldbach_conjecture() -> u64 {
    let first = find_num(1);
    let second = find_num(first);
    // dbg!(first, second, first + second);
    first + second
}
